package io.renren.modules.app.controller;

import io.renren.common.result.Result;
import io.renren.modules.medical.vo.weixinVo.ApiNavigationVo;
import io.renren.modules.medical.vo.weixinVo.ApiSwiperVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * 获取静态图片的Api
 * @author Luo Sheng
 * @school YiBin university
 * @create 2023-04-23 11:28
 */
@RestController
@RequestMapping("/app/static")
public class StaticApi {

    /**
     *
     * 获取轮播图静态图片
     * @return
     */
    @GetMapping("/swiper")
    public Result<ArrayList<ApiSwiperVo>> getSwiper(){
        ArrayList<ApiSwiperVo> swiperList = new ArrayList<>();
        String baseUrl = "https://gonitis-lush.oss-cn-chengdu.aliyuncs.com/static/swiper/swiper";
        for (int i = 1; i < 4; i++){
            ApiSwiperVo apiSwiperVo = new ApiSwiperVo();
            apiSwiperVo.setImgSrc(baseUrl + i + ".png");
            swiperList.add(apiSwiperVo);
        }
        return Result.success(swiperList);

    }

    /**
     * 获得导航栏数据
     * @return
     */
    @GetMapping("/navigation")
    public Result<ArrayList<ApiNavigationVo>> getNavigation(){
        String baseUrl = "https://gonitis-lush.oss-cn-chengdu.aliyuncs.com/static/navigation/";
        String[] urls = {"binqing.png", "suifang.png", "jiance.png", "tixing.png", "yaopin.png", "jiankang.png", "yongyaojianyi.png"};
        String[] titles = {"我的病情", "我的随访", "自我评测", "用药提醒", "用药记录", "健康管理", "用药建议"};
        String[] navUrls = {"/pages/my_illness/my_illness", "/pages/my_follow/my_follow", "/pages/question_list/question_list", "", "/pages/medication_history/medication_history", "/pages/health_admin/health_admin", "/pages/medication_advice/medication_advice"};
        ArrayList<ApiNavigationVo> navigationVos = new ArrayList<>();
        for (int i = 0; i < urls.length; i++){
            ApiNavigationVo apiNavigationVo = new ApiNavigationVo();
            apiNavigationVo.setImgSrc(baseUrl + urls[i]);
            apiNavigationVo.setTitle(titles[i]);
            apiNavigationVo.setNavUrl(navUrls[i]);
            navigationVos.add(apiNavigationVo);
        }
        return Result.success(navigationVos);
    }


}
